package chapter15.exercise;

import com.common.utils.Generator;

public class BaseGenerator<T> implements Generator<T> {
    private Class<T> t;

    public BaseGenerator(Class<T> cla) {
        this.t = cla;
    }

    public T next() {
        try {
            return t.newInstance();
        } catch (Exception e) {
            throw new RuntimeException();
        }
    }

    public static <T> BaseGenerator<T> create(Class<T> cla) {
        return new BaseGenerator<>(cla);
    }

}
